package se.wangs.clonedemo;

import se.wangs.clonedemo.pojo.Student;
import se.wangs.clonedemo.pojo.Teacher;

/**
 * -- coding: UTF-8 -- *
 *
 * @author wangs
 * @date 2023/12/6 10:09
 * @description 深拷贝
 */
public class DeepClone {
    public static void main(String[] args) {
        Teacher teacher1 = new Teacher();
        teacher1.setIdNo("001");
        teacher1.setName("teacher_001");

        Student student1 = new Student();
        student1.setIdNo("101");
        student1.setName("student_101");
        student1.setTeacher(teacher1);

        Student cloneStudent = student1.clone();

        System.out.println("---------------------------");
        System.out.println(student1);
        System.out.println("idNo = " + student1.getIdNo());
        System.out.println("name = " + student1.getName());
        System.out.println("teacher = " + student1.getTeacher());

        System.out.println("---------------------------");
        System.out.println(cloneStudent);
        System.out.println("idNo = " + cloneStudent.getIdNo());
        System.out.println("name = " + cloneStudent.getName());
        System.out.println("teacher = " + cloneStudent.getTeacher());
    }
}
